#include <stdio.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

#define TRACE(x...) 
#define PRINT(x...) TRACE(printf(x))

#define rep(i,n) for (int i=0; i<n; i++)
#define inter(i,a,b) for (int i=a; i<b; i++)

#define oo 0x3f3f3f3f

#define f first
#define s second
#define mp make_pair

char tmp; int a;
char mat[8][8];
int kx, ky;
int rx, ry;
int d[8][2] = {{1, 2}, {-1, 2},
		{-1, -2}, {1, -2},
		{2, 1}, {2, -1},
		{-2, -1}, {-2, 1}};
int dx, dy;
int pos;
int fl;
int att[8][2]; int nAtt;

int main() {
	rep(i,8) rep(j,8) mat[i][j]='.';
	
	scanf(" %c", &tmp);	
	scanf("%d", &a); a--;
	mat[tmp-'a'][a]='R';
	rx=tmp-'a'; ry=a;

	scanf(" %c", &tmp);	
	scanf("%d", &a); a--;
	mat[tmp-'a'][a]='K';
	kx=tmp-'a'; ky=a;

	PRINT("Knight: %d, %d\n", kx, ky);
	PRINT("Rook: %d, %d\n", rx, ry);

	TRACE(
		rep(i,8) {
			rep(j,8) printf("%c ", mat[i][j]);
			printf("\n");
		}
		printf("\n");
	)
	
	rep(k,8) {
		dx=kx+d[k][0];
		dy=ky+d[k][1];

		if (dx<0 || dx>=8) continue;
		if (dy<0 || dy>=8) continue;

		att[nAtt][0]=dx; att[nAtt][1]=dy;
		nAtt++;
	}

	pos=0;

	rep(i,8) rep(j,8) {
		if (mat[i][j]!='.') continue;
		fl=0;		

		rep(k,8) {
			dx=i+d[k][0];
			dy=j+d[k][1];

			if (dx<0 || dx>=8) continue;
			if (dy<0 || dy>=8) continue;

			if (mat[dx][dy]!='.') { fl=1; break; }
		}

		if (fl) continue;

		rep(k, nAtt) {
			if (att[k][0]==i && att[k][1]==j) { fl=1; break; }
		}

		if (fl) continue;

		if (i==rx) continue; if (j==ry) continue;
		pos++;
	}

	printf("%d\n", pos);

	return 0;
}
